<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>AdminLTE | PersRight</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <link href="../static/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <!-- Ionicons -->
    <link href="../static/css/ionicons.min.css" rel="stylesheet" type="text/css"/>
    <!-- Theme style -->
    <link href="../static/css/AdminLTE.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/right/common.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/right/slide.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/right/flat-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/right/jquery.nouislider.css">
    <!--<script type="text/javascript">
        $(function () {
            var isAddOky = [[${isAddOky}]]
            if(isAddOky) {
                $.message('添加成功');
            } else{
                $.message({
                    message: '添加失败',
                    type: 'error'
                });
            }

            var isUpdateOky = [[${isUpdateOky}]]
            if(isUpdateOky) {
                $.message('修改成功');
            } else{
                $.message({
                    message: '修改失败',
                    type: 'error'
                });
            }

            var isDeleteOky = [[${isDeleteOky}]]
            if(isDeleteOky) {
                $.message('删除成功');
            } else{
                $.message({
                    message: '删除失败',
                    type: 'error'
                });
            }
        })
    </script>-->
    <style>
        span1 {
            color: red;
        }
    </style>
</head>
<body class="skin-blue" style="overflow: hidden">
<!-- header logo: style can be found in header.less -->
<header class="header">
    <a href="index.html" class="logo">
        <!-- Add the class icon to your logo image or logo icon to add the margining -->
        AdminLTE
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top" role="navigation">
        <!-- Sidebar toggle button-->
        <a href="#" class="navbar-btn sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </a>
        <div class="navbar-right">
            <ul class="nav navbar-nav">
                <!-- User Account: style can be found in dropdown.less -->
                <li class="dropdown user user-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="glyphicon glyphicon-user"></i>
                        <span>个人中心<i class="caret"></i></span>
                    </a>
                    <ul class="dropdown-menu">
                        <!-- User image -->
                        <li class="user-header bg-light-blue">
                            <img src="../static/img/pers/rw1.png" class="img-circle" alt="User Image"/>
                            <p>
                                我
                            </p>
                        </li>
                        <!-- Menu Body -->
                        <li class="user-body">
                            <div class="col-xs-4 text-center">
                                <a href="/findManger">个人信息</a>
                            </div>
                            <div class="col-xs-4 text-center">
                                <a href="/findAllLogs">操作日志</a>
                            </div>
                            <div class="col-xs-4 text-center">
                                <a href="/login">退出登录</a>
                            </div>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
</header>
<div class="wrapper row-offcanvas row-offcanvas-left">
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="left-side sidebar-offcanvas">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- Sidebar user panel -->
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="../static/img/pers/rw1.png" class="img-circle" alt="User Image"/>
                </div>
                <div class="pull-left info">
                    <p>你好，管理员</p>

                    <a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
                </div>
            </div>
            <!-- search form -->
            <form action="#" method="get" class="sidebar-form">
                <div class="input-group">
                    <input type="text" name="search" class="form-control" placeholder="搜索..."/>
                    <span class="input-group-btn">
                                <button type='submit' name='searchtoUrl' id='search-btn' class="btn btn-flat"><i
                                        class="fa fa-search"></i></button>
                            </span>
                </div>
            </form>
            <!-- /.search form -->
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu">
                <li>
                    <a href="index.html">
                        <i class="fa fa-dashboard"></i> <span>首页</span>
                    </a>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa fa-bar-chart-o"></i>
                        <span>日志管理</span>
                        <i class="fa fa-angle-left pull-right"></i>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/LogCatchPre"><i class="fa fa-angle-double-right"></i> 日志获取</a></li>
                        <li><a href="LogAnalysis.html"><i class="fa fa-angle-double-right"></i> 日志分析</a></li>
                        <li><a href="LogWarn.html"><i class="fa fa-angle-double-right"></i> 日志报警</a></li>
                    </ul>
                </li>
                <li class="treeview active">
                    <a href="#">
                        <i class="fa fa-table"></i> <span>系统管理</span>
                        <i class="fa fa-angle-left pull-right"></i>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/SysRightPre"><i class="fa fa-angle-double-right"></i> 权限管理</a></li>
                        <li class="active"><a href="/PersRight.html" onclick="function getManagerList() {
                            $.ajax(
                                    {
                                      type:'get',
                                      url:'/PersRightPre',
                                      date:{
                                      pageNum:0,
                                      pageSize:8
                                    },
                                     dataType:'json',
                                    }
                                  )
                            }
                        getManagerList()"><i class="fa fa-angle-double-right"></i>人员管理</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="calendar.html">
                        <i class="fa fa-calendar"></i> <span>日历</span>

                    </a>
                </li>
                <li>
                    <a href="/findAllMailsInBox">
                        <i class="fa fa-envelope"></i> <span>邮箱</span>

                    </a>
                </li>
            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>
    <!-- Right side column. Contains the navbar and content of the page -->
    <aside class="right-side">
        <section class="content-header">
            <h1>
                人员管理
                <small>Control panel</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li class="active">人员管理</li>
            </ol>
        </section>
        <!-- Main content -->
        <section class="content">
            <!--用户管理模块-->
            <div role="tabpanel" class="tab-pane" id="user">
                <div class="check-div form-inline">
                    <div class="col-xs-3">
                        <button class="btn btn-yellow btn-xs" data-toggle="modal" data-target="#addManager">添加用户
                        </button>
                    </div>
                    <!--<form action="/findAllManagers" method="post">
                        <div class="col-xs-4">
                            <input type="text" class="form-control input-sm" placeholder="输入文字搜索">
                            <button type="submit" class="sbbtn">搜索</button>
                        </div>
                    </form>-->
                </div>
                <div class="container1" id="container1" style="display: block" th:if="${allManagerList}!=null">
                    <div class="row1 clearfix">
                        <div class="col-md-12 column">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>用户名</th>
                                        <th>用户类型</th>
                                        <th>姓名</th>
                                        <th>性别</th>
                                        <th>年龄</th>
                                        <th>地址</th>
                                        <th>邮箱</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr th:each="allManagerList:${allManagerList}">
                                        <td th:text="${allManagerList.id}"></td>
                                        <td th:text="${allManagerList.managerType}"></td>
                                        <td th:text="${allManagerList.name}"></td>
                                        <td th:text="${allManagerList.sex}"></td>
                                        <td th:text="${allManagerList.age}"></td>
                                        <td th:text="${allManagerList.location}"></td>
                                        <td th:text="${allManagerList.email}"></td>
                                        <td>
                                            <button class="btn btn-success btn-xs" data-toggle="modal"
                                                    data-target="#UpdateManager"
                                                    th:onclick="updateM([[${allManagerList.id}]],[[${allManagerList.name}]],[[${allManagerList.sex}]],
                                                    [[${allManagerList.age}]],[[${allManagerList.location}]],[[${allManagerList.email}]])">修改
                                            </button>
                                            <button class="btn btn-danger btn-xs" data-toggle="modal"
                                                    data-target="#deleteManager"
                                                    th:onclick="deleteM([[${allManagerList.id}]])">删除
                                            </button>
                                        </td>
                                        <!--th:onclick="'javascript:updM('+${managerList.id}+')'"
                                        th:onclick="'javascript:delM('+${managerList.id}+')'"-->
                                    </tr>
                                    </tbody>
                                </table>
                                <div class="modal-footer no-margin-top">
                                    <ul class="pagination pull-right no-margin">
                                        <!-- 首页 -->
                                        <li>
                                            <a th:href="'/PersRightPre?pageNum=0'"
                                               style="font-weight: bold;background-color: #6faed9;">首页</a>
                                        </li>
                                        <!-- 上一页 -->
                                        <li th:if="${allManagerList.hasPrevious()}">
                                            <a th:href="'/PersRightPre?pageNum=' + ${allManagerList.previousPageable().getPageNumber()}"
                                               th:text="上一页" style="font-weight: bold;background-color: #6faed9;"></a>
                                        </li>
                                        <!-- 中间页 -->
                                        <li th:each="pageNum:${#numbers.sequence(0, allManagerList.getTotalPages() - 1)}">
                                            <a th:href="'/PersRightPre?pageNum=' + ${pageNum}" th:text="${pageNum + 1}"
                                               th:if="${pageNum ne allManagerList.pageable.getPageNumber()}"
                                               style="font-weight: bold;background-color: #6faed9;"></a>
                                            <a th:href="'/PersRightPre?pageNum=' + ${pageNum}" th:text="${pageNum + 1}"
                                               th:if="${pageNum eq allManagerList.pageable.getPageNumber()}"
                                               th:style="'font-weight:bold;background: #6faed9;'"></a>
                                        </li>
                                        <!-- 下一页 -->
                                        <li th:if="${allManagerList.hasNext()}">
                                            <a th:href="'/PersRightPre?pageNum=' + ${allManagerList.nextPageable().getPageNumber()}"
                                               th:text="下一页" style="font-weight: bold;background-color: #6faed9;"></a>
                                        </li>
                                        <!-- 尾页 -->
                                        <li>
                                            <a th:href="'/PersRightPre?pageNum=' + ${allManagerList.getTotalPages() - 1}"
                                               style="font-weight: bold;background-color: #6faed9;">尾页</a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section><!-- /.content -->
    </aside><!-- /.right-side -->
</div><!-- ./wrapper -->
<!--弹出添加用户窗口-->
<div class="modal fade" id="addManager" role="dialog" aria-labelledby="gridSystemModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="gridSystemModalLabel1">添加用户</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <form class="form-horizontal" action="" method="post" id="addform" onsubmit="getUrl1()">
                        <div class="form-group ">
                            <label class="col-xs-3 control-label">用户名：</label>
                            <div class="col-xs-8 ">
                                <input type="text" class="form-control input-sm duiqi" id="MName1" name="MName1"
                                       value="" required="required"
                                       onblur="checkId()">
                                <span1 id="errorName"></span1>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">用户类型：</label>
                            <div class="col-xs-8">
                                <!--<select class=" form-control select-duiqi" id="MType1" name="MType1">
                                    <option value="">管理员</option>
                                </select>-->
                                <input type="text" class="form-control input-sm duiqi" id="MType1" name="MType1"
                                       value="管理员" readonly="readonly">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">真实姓名：</label>
                            <div class="col-xs-8">
                                <input type="text" class="form-control input-sm duiqi" id="MRName1" name="MRName1"
                                       required="required">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">性别：</label>
                            <input type="radio" name="MSex1" value="男" checked="checked"/>男
                            <input type="radio" name="MSex1" value="女"/>女
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">年龄：</label>
                            <div class="col-xs-8">
                                <input type="number" id="MAge1" name="MAge1" min="20" max="50" step="1" value="20"
                                       required="required">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">地址：</label>
                            <div class="col-xs-8">
                                <input type="text" class="form-control input-sm duiqi" id="MAddr1" name="MAddr1"
                                       required="required">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">邮箱：</label>
                            <div class="col-xs-8">
                                <input type="email" class="form-control input-sm duiqi" id="MEmail1" name="MEmail1"
                                       pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}" required="required" onblur="checkMail()"/>
                                <span1 id="errorMail" class="col"></span1>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="button" class="btn btn-xs btn-white" data-dismiss="modal" value="取消">
                            <input type="submit" class="btn btn-xs btn-green" value="保存">
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!--弹出修改用户窗口-->
<div class="modal fade" id="UpdateManager" role="dialog" aria-labelledby="gridSystemModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="gridSystemModalLabel2">修改用户</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <form class="form-horizontal" action="#" id="updateform" method="get" onsubmit="getUrl2()">
                        <div class="form-group ">
                            <label class="col-xs-3 control-label">用户名：</label>
                            <div class="col-xs-8 ">
                                <input type="text" class="form-control input-sm duiqi" id="MName2" name="MName2"
                                       value="" readonly="true"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">真实姓名：</label>
                            <div class="col-xs-8">
                                <input type="text" class="form-control input-sm duiqi" id="MRName2" name="MRName2"
                                       value="" required="required"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">性别：</label>
                            <input type="radio" name="MSex2" value="男" checked="checked"/>男
                            <input type="radio" name="MSex2" value="女"/>女
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">年龄：</label>
                            <div class="col-xs-8">
                                <input type="number" id="MAge2" name="MAge2" min="20" max="50" step="1" value="20"
                                       required="required"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">地址：</label>
                            <div class="col-xs-8">
                                <input type="text" class="form-control input-sm duiqi" id="MAddr2" name="MAddr2"
                                       value="" required="required"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-3 control-label">邮箱：</label>
                            <div class="col-xs-8">
                                <input type="email" class="form-control input-sm duiqi" id="MEmail2" name="MEmail2"
                                       value="" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}" required="required"/>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-xs btn-white" data-dismiss="modal">取 消</button>
                            <button type="submit" class="btn btn-xs btn-green">确 定</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!--弹出删除用户警告窗口-->
<div class="modal fade" id="deleteManager" role="dialog" aria-labelledby="gridSystemModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="#" method="get" id="delform" onsubmit="getUrl3()">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="gridSystemModalLabel">提示</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" id="MName3" name="MName3" value=""/>
                    <input type="hidden" id="Mass" name="Mass" value=""/>
                    <div class="container-fluid">
                        确定要删除用户？删除后不可恢复！
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-xs btn-white" data-dismiss="modal">取 消</button>
                    <button type="submit" class="btn btn-xs btn-green">确 定</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<script src="../static/js/right/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../static/js/bootstrap.min.js" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="../static/js/AdminLTE/app.js" type="text/javascript"></script>
<!-- Bootstrap WYSIHTML5 -->
<!--<script src="../static/js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>-->
<!-- iCheck -->
<script src="../static/js/plugins/iCheck/icheck.min.js" type="text/javascript"></script>

<script src="../static/js/right/jquery.nouislider.js"></script>

<!--<script src="../static/js/right/jquery.min.js"></script>-->
<!--<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script src="../static/js/message/message.min.js"></script>-->
</body>
<script type="text/javascript">
    /*$("#UpdateManager").modal("hide");*/

    function updateM(ID, NAME, SEX, AGE, LOCATION, EMAIL) {
        $("#MName2").val(ID);
        /*$('input:radio:checked').val();*/
        $("#MSex2").val(SEX);
        $("#MRName2").val(NAME);
        $("#MAge2").val(AGE);
        $("#MAddr2").val(LOCATION);
        $("#MEmail2").val(EMAIL);
    }


   /* $("#deleteManager").modal("hide");*/

    function deleteM(ID) {
        $("#MName3").val(ID);

    }

</script>
<script type="text/javascript">
    //添加用户的用户名校验
    function checkId() {

        var MName1 = $.trim($("#MName1").val());
        $("#errorName").html("");
        $.ajax({
            url: '/checkManagerId',
            type: 'POST',
            data: {"name":MName1},
            dataType: "json",
            success: function (result) {
                // 数据库中存在该用户名
                if (result.res==true) {
                    $("#errorName").html("该用户名已被使用！");
                    return false;
                } else{
                    $("#errorName").html("该用户名可以使用");
                }
            },
            error: function () {
                $("#errorName").html("校验用户名时出错！");
            }
        });
    }
</script>
<script type="text/javascript">
    function checkMail() {
        var EMAIL = $.trim($("#MEmail1").val());

        // 校验用户邮箱是否存在,该URL可以返回该用户名存在的数量
        $.ajax({
            url: '/checkManagerEmail',
            type: 'POST',
            data: {"email":EMAIL},
            dataType: "json",
            success: function (result) {
                // 数据库中存在该用户名
                if (result.res==true) {
                    $("#errorMail").html("该邮箱已被使用！");
                    return false;
                } else {
                    $("#errorMail").html("该邮箱可以使用！");
                }
            },
            error: function () {
                $("#errorMail").html("校验邮箱出现错误！");
            }
        });
    }
</script>
<script type="text/javascript">
    function getUrl1() {
        const myurl = '/addManager';
        $("#addform").attr("action", myurl);
    }

    function getUrl2() {
        const myurl = '/updateManager?id=' + $("#MName2").val();
        $("#updateform").attr("action", myurl);
    }

    function getUrl3() {
        const myurl = '/deleteManager?id=' + $("#MName3").val();
        $("#delform").attr("action", myurl);
    }
</script>
<!--<script type="text/javascript">
    $(document).ready(function () {
        if([[${session?.isdelok}]] == true){
            alert("删除成功")
        }

        if([[${session?.isudok}]] == true){
            alert("修改成功")
        }
        if([[${session?.isaddok}]] == true){
            alert("添加成功")
        }
    });
</script>-->
</html>